import api from "@/util/api";

async function findAll(){
    let resp = await api({
        url:"/category-api/api/v1/category/all",
        method:"get",
    })
    return resp.data
}
async function findTree(){
    let resp = await api({
        url:"/category-api/api/v1/category/tree",
        method:"get",
    })
    return resp.data
}
async function deleteByIds(ids) {
    let resp = await api({
        url: "/category-api/api/v1/category/delete",
        method: "delete",
        params: { ids: ids },
        paramsSerializer: {
            indexes: null // 确保参数格式为 ids=1&ids=2
        }
    });
    return resp;
}



async function save(category){
    let resp = await api({
        url:"/category-api/api/v1/category/add",
        method:"post",
        data:category
    })
    return resp
}

async function update(category){
    let resp = await api({
        url:"/category-api/api/v1/category/update",
        method:"put",
        data:category
    })
    return resp
}

async function updateIsLook(id,isLook){
    let resp = await api({
        url:"/categories/isLook",
        method:"put",
        params:{
            id,
            isLook
        }
    });
    return resp;
}
export {findAll, deleteByIds, save, update,findTree,updateIsLook};
